/**
 * 
 */
package sailing.dao.impl;

import java.util.List;

import org.apache.commons.dbutils.QueryRunner;

import cjlite.daosupport.BaseDao;
import cjlite.daosupport.SqlHelper;
import cjlite.logger.Logger;
import cjlite.utils.Lists;

import sailing.dao.AccountingSubjectDao;
import sailing.entity.AccountingSubject;

/**
 * @author kevin
 * 
 */
public class AccountingSubjectDaoImpl extends BaseDao implements AccountingSubjectDao {
	private static Logger logger = Logger.thisClass();

	/*
	 * (non-Javadoc)
	 * 
	 * @see sailing.dao.AccountingSubjectDao#getAllSubjectList()
	 */
	@Override
	public List<AccountingSubject> getAllSubjectList() {
		return this.selectAll(AccountingSubject.class);
	}

	@Override
	public boolean save(AccountingSubject as) {
		return this.persist(as);
	}

	
	private SqlHelper selectSql = SqlHelper.selectSql("AccountingSubject").where(" parentId = ?");
	@Override
	public List<AccountingSubject> getSubjectListByCateId(int code) {
		logger.entry();
		try {
			QueryRunner qr = this.getQueryRunner();
			List<AccountingSubject> cList = qr.query(selectSql.toSqlString(), this.getBeanListHandler(AccountingSubject.class),code);
			return cList;
		} catch (Exception e) {
			logger.error("error on select all '{0}' as list ~~", e, AccountingSubject.class.getName());
		}
		logger.exit();
		return Lists.newArrayList();
	}

	@Override
	public boolean update(AccountingSubject as) {
		return super.update(as);
	}

	@Override
	public boolean delete(AccountingSubject as) {
		return super.delete(as);
	}

}
